<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars2d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,二维,地图,地球,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 二维 地图 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 二维地图 全景漫游 地理信息系统 云GIS 二维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="//mars2d.cn/favicon.ico" />
    <title>layers 叠加图层 | Mars2D | 地理信息平台 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars2d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <div id="mars2dContainer" class="mars2d-container"></div>

    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      $(document).ready(function () {
        initMap();
      });

      function initMap() {
        //添加可叠加图层有3种方式（参数除指定的type类型外无需type参数，其他参数都相同）:

        //方式1：在创建地图前的传参中配置layers参数
        let map = new mars2d.Map("mars2dContainer", {
          zoom: 5,
          center: { lng: 110.522461, lat: 37.509726 },
          control: {
            layers: { position: "topleft" },
          },
          basemaps: [
            {
              id: 2021,
              pid: 10,
              name: "天地图电子",
              icon: "img/basemaps/tianditumap.png",
              type: "group",
              layers: [
                {
                  name: "底图",
                  type: "tdt",
                  layer: "vec_d",
                  key: ["bcc62222fc634ec736589c483de933e6"],
                },
                {
                  name: "注记",
                  type: "tdt",
                  layer: "vec_z",
                  key: ["bcc62222fc634ec736589c483de933e6"],
                },
              ],
              show: true,
            },
          ],
          operationallayers: [
            {
              name: "中国地质",
              type: "tile",
              url: "//data.mars3d.cn/tile/dizhiChina/{z}/{x}/{y}.png",
              minZoom: 0,
              maxZoom: 10,
              rectangle: { xmin: 69.706929, xmax: 136.560941, ymin: 15.831038, ymax: 52.558005 },
            },
            { name: "经纬网", type: "graticule" },
          ],
        });

        //方式2：在创建地图后调用addLayer添加图层(直接new对应type类型的图层类)
        let layer = new mars2d.layer.TileLayer({
          name: "行政区划界线",
          url: "https://t{s}.tianditu.gov.cn/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=9ae78c51a0a28f06444d541148496e36",
          subdomains: "01234567",
          maxZoom: 10,
        });
        map.addLayer(layer);

        //方式3：在创建地图后调用addLayer添加图层(用 mars2d.layer.create工厂方法创建)
        let layerImg = mars2d.LayerUtil.create({
          type: "image",
          url: "//data.mars2d.cn/file/img/radar/201906211112.PNG",
          rectangle: { xmin: 73.16895, xmax: 134.86816, ymin: 12.2023, ymax: 54.11485 },
          alpha: 0.7,
        });
        map.addLayer(layerImg);
      }
    </script>
  </body>
</html>
